package org.mcclone.platy.web;

import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.redisson.client.codec.StringCodec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redisson")
public class RedissonController {

    private final StringRedisTemplate redisTemplate;

    private final RedissonClient redissonClient;

    @Autowired
    public RedissonController(StringRedisTemplate redisTemplate, RedissonClient redissonClient) {
        this.redisTemplate = redisTemplate;
        this.redissonClient = redissonClient;
    }

    @RequestMapping("/index")
    public void index() {
        RBucket<String> bucket = redissonClient.getBucket("1", new StringCodec());
        String value = redisTemplate.opsForValue().get("1");
        System.out.println(value);
        System.out.println(bucket.get());
    }
}
